﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Windows.Forms;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Nmo;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Trace;

namespace Entity
{
    public class LOPHOC
    {
        DataBaseAccess dataBaseAccess = new DataBaseAccess();


        private String MALOP, TENLOP, MAKHOA, MAHDT, MAGV;
        private int SISO;
        private float HESOGD;

        public String maLop
        {
            get { return MALOP; }
            set { MALOP = value; }
        }

        public String tenLop
        {
            get { return TENLOP; }
            set { TENLOP = value; }
        }

        public String maKhoa
        {
            get { return MAKHOA; }
            set { MAKHOA = value; }
        }

        public String maHDT
        {
            get { return MAHDT; }
            set { MAHDT = value; }
        }

        public String maGV
        {
            get { return MAGV; }
            set { MAGV = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public int siso
        {
            get { return SISO; }
            set { SISO = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public float hesoGD
        {
            get { return HESOGD; }
            set { HESOGD = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dtgLopHoc"></param>

        public void hienthi_LopHoc(DataGridView dtgLopHoc)
        {
            String excuteString = "SELECT * FROM LOPHOC";
            DataTable dataTable = new DataTable();
            dataTable = dataBaseAccess.getDataTable(excuteString);
            dtgLopHoc.DataSource = dataTable;
        }

        public void xoa_LopHoc(String malophoc)
        {
            String excuteString = "DELETE FROM LOPHOC WHERE MALOP ='" + malophoc + "'";
            dataBaseAccess.excuteNonQuery(excuteString);
        }

        public void them_LopHoc(LOPHOC lophoc)
        {
            String excuteString = "INSERT INTO LOPHOC VALUES ('" + lophoc.maLop + "','"
                                                                 + lophoc.tenLop + "','"
                                                                 + lophoc.maKhoa + "','"
                                                                 + lophoc.maHDT + "',"
                                                                 + lophoc.siso + ",'"
                                                                 + lophoc.maGV + "',"
                                                                 + lophoc.hesoGD + ")";
            dataBaseAccess.excuteNonQuery(excuteString);
        }

        public void sua_LopHoc(LOPHOC lophoc)
        {
            String excuteString = "UPDATE LOPHOC SET TENLOP ='" + lophoc.tenLop +
                                                  "', MAKHOA ='" + lophoc.maKhoa +
                                                  "', MAHDT ='" + lophoc.maHDT +
                                                  "', SISO =" + lophoc.siso +
                                                  ",MAGVCN ='" + lophoc.maGV +
                                                  "',HESOGD =" + lophoc.hesoGD +
                                                  "WHERE MALOP ='" + lophoc.maLop + "'";
            dataBaseAccess.excuteNonQuery(excuteString);
        }

    }
}
